# -*- coding: utf-8 -*-
# @Time : 2024/6/22 10:40 PM 
# @Author : Wayne
# @Email : 1
# @File : readfile.py
# @Project : young_python_demo
# @DESCRIPTION :
import json

def read_and_process_file(filename, keys_to_keep):
    result = []

    # 读取文件
    with open(filename, 'r') as file:
        content = file.read()
        # 将内容解析为Python对象
        data = json.loads(content)
        # data = data.get("List")
        # 处理数据，只保留特定的键值对
        FItemIDs = [entry['FItemID'] for item in data['data']['List'] if 'Entry' in item for entry in item['Entry']]


    return FItemIDs

filename = 'kis_baowen.txt'  # 你的文件名
keys_to_keep = ["id", "itemCode", "itemName", "pjCode", "pjName", "upCode", "upName"]  # 你想要保留的键

new_data = read_and_process_file(filename, keys_to_keep)

unique_FItemIDs = set(new_data)

print(unique_FItemIDs)
